// pages/home/home.js
import silcepage from '../../listsilce.js'
var sliderWidth = 96;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabbar:false,
    tabbarlist:[],
    tabs: ["商店", "游戏", "软件","硬件","社区"],
    activeIndex: 1,
    sliderOffset: 0,
    sliderLeft: 0,
    list: ['one', 'two', 'third', 'four'],
    imgUrls: [
      '../../assets/pretys/come.jpg',
      '../../assets/pretys/pika.jpg',
      '../../assets/pretys/game.jpg',
      '../../assets/pretys/pubg.jpg',
      '../../assets/pretys/three.jpg',
      '../../assets/pretys/timg.jpg'
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 2000,
    duration: 1000,
    circular:true,
    inputShowed: false,
    inputVal: "",
    introduceimgurls:[
      '../../assets/pretys/a.jpg',
      '../../assets/pretys/b.jpg',
      '../../assets/pretys/c.jpg',
      '../../assets/pretys/d.jpg',
      '../../assets/pretys/e.jpg',
      '../../assets/pretys/f.jpg' 
    ],
    banner:[
      { url:'../../assets/pretys/g.jpg',
        title:'疯狂周',
        desc:'特惠于周日上午 10 点止（太平洋时间）',
        num:'-50%',
        number:(Math.random()*100).toFixed(0)},
      {
        url: '../../assets/pretys/h.jpg',
        title: '疯狂周',
        desc: '特惠于周日上午 10 点止（太平洋时间）',
        num: '-50%',
        number: (Math.random()*100).toFixed(0)
      },
      {
        url: '../../assets/pretys/i.jpg',
        title: '疯狂周',
        desc: '特惠于周日上午 10 点止（太平洋时间）',
        num: '-50%',
        number: (Math.random()*100).toFixed(0)
      },
      {
        url: '../../assets/pretys/j.jpg',
        title: '疯狂周',
        desc: '特惠于周日上午 10 点止（太平洋时间）',
        num: '-50%',
        number: (Math.random()*100).toFixed(0)
      },
      {
        url: '../../assets/pretys/k.jpg',
        title: '疯狂周',
        desc: '特惠于周日上午 10 点止（太平洋时间）',
        num: '-50%',
        number: (Math.random()*100).toFixed(0)
      },
      {
        url: '../../assets/pretys/l.jpg',
        title: '疯狂周',
        desc: '特惠于周日上午 10 点止（太平洋时间）',
        num: '-50%',
        number: (Math.random()*100).toFixed(0)
      },
      {
        url: '../../assets/pretys/m.jpg',
        title: '疯狂周',
        desc: '特惠于周日上午 10 点止（太平洋时间）',
        num: '-50%',
        number: (Math.random()*100).toFixed(0)
      },
      {
        url: '../../assets/pretys/n.jpg',
        title: '疯狂周',
        desc: '特惠于周日上午 10 点止（太平洋时间）',
        num: '-50%',
        number: (Math.random()*100).toFixed(0)
      } 
    ]
  }, 
  delete() {
    if (this.data.list.length !== 0) {
      this.setData({
        list: []
      })
    } else {
      this.setData({
        list: ['one', 'two', 'third', 'four']
      })
    }
  },
  showInput: function () {
    this.setData({
      inputShowed: true
    });
  },
  hideInput: function () {
    this.setData({
      inputVal: "",
      inputShowed: false
    });
  },
  clearInput: function () {
    this.setData({
      inputVal: ""
    });
  },
  inputTyping: function (e) {
    this.setData({
      inputVal: e.detail.value
    });
  },
  onLoad: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
          sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
        });
      }
    });
  },
  tabClick: function (e) {
    this.setData({
      sliderOffset: e.currentTarget.offsetLeft,
      activeIndex: e.currentTarget.id,
      tabbar: !this.data.tabbar,
      tabbarlist: silcepage(e.currentTarget.id, 5)
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})